define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'map/order/index' + location.search,
                    add_url: 'map/order/add',
                    edit_url: 'map/order/edit',
                    del_url: 'map/order/del',
                    multi_url: 'map/order/multi',
                    import_url: 'map/order/import',
                    table: 'map_order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'shop_name', title: __('Shop_name'), operate: 'LIKE'},
                        {field: 'shop_address', title: __('Shop_address'), operate: 'LIKE'},
                        {field: 'connect_name', title: __('Connect_name'), operate: 'LIKE'},
                        {field: 'connect_phone', title: __('Connect_phone'), operate: 'LIKE'},
                        // {field: 'map_id', title: __('Map_id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        {field: 'money', title: __('Money'), operate:'BETWEEN'},
                        {field: 'type', title: __('Type'), searchList: {"alipay":__('Alipay'),"wxpay":__('Wxpay')}, formatter: Table.api.formatter.normal},
                        {field: 'out_trade_no', title: __('Out_trade_no')},
                        // {field: 'notify_url', title: __('Notify_url'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        {field: 'pid', title: __('Pid')},
                        // {field: 'cid', title: __('Cid')},
                        // {field: 'param', title: __('Param'), operate: 'LIKE'},
                        // {field: 'return_url', title: __('Return_url'), operate: 'LIKE', formatter: Table.api.formatter.url},
                        // {field: 'sign_type', title: __('Sign_type'), operate:'BETWEEN'},
                        {field: 'createtime', title: __('提交时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
                        {field: 'pay_status', title: __('Pay_status'), searchList: {"1":__('成功'),"0":__('失败')}, formatter: Table.api.formatter.status},
                        {field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        // {field: 'info.name', title: __('Info.name'), operate: 'LIKE'},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
